import { Employee } from "@prisma/client"

interface PerformanceReportProps {
  employees: Employee[]
}

export function PerformanceReport({ employees }: PerformanceReportProps) {
  return (
    <div className="overflow-x-auto">
      <table className="min-w-full divide-y divide-gray-200">
        <thead className="bg-gray-50">
          <tr>
            <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">员工姓名</th>
            <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">总业绩</th>
            <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">销售数量</th>
            <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">创建时间</th>
          </tr>
        </thead>
        <tbody className="bg-white divide-y divide-gray-200">
          {employees.map((employee) => {
            const totalSales = employee.sales.reduce((sum, sale) => sum + sale.amount, 0)
            return (
              <tr key={employee.id}>
                <td className="px-6 py-4 whitespace-nowrap text-gray-700">{employee.name}</td>
                <td className="px-6 py-4 whitespace-nowrap text-gray-700">¥{totalSales.toFixed(2)}</td>
                <td className="px-6 py-4 whitespace-nowrap text-gray-700">{employee.sales.length}</td>
                <td className="px-6 py-4 whitespace-nowrap text-gray-700">{new Date(employee.createdAt).toLocaleString()}</td>
              </tr>
            )
          })}
        </tbody>
      </table>
    </div>
  )
} 